﻿<demos:DemoItem x:Class="DemoApplication.Demos.Controls.ActiveIconElement"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:bh="http://www.brokenhouse.co.uk/wpf"
                xmlns:demos="clr-namespace:DemoApplication.Demos"
                Group="Controls" Label="Active Icon" MaxWidth="1000">
    
    <demos:DemoItem.Resources>
        <Style x:Key="Styled" TargetType="{x:Type bh:ActiveIcon}">
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect ShadowDepth="2" BlurRadius="5" Opacity="0.6"/>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type bh:ActiveIcon}">
                        <bh:Icon x:Name="PART_Renderer" Source="{TemplateBinding Source}" 
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                Margin="{TemplateBinding Padding}" Opacity="0.8"/>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="ColorTransform" TargetName="PART_Renderer">
                                    <Setter.Value>
                                        <bh:DesaturationTransform Amount="1.0"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition  Property="IsActive" Value="True"/>
                                    <Condition  Property="IsEnabled" Value="True"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Opacity" TargetName="PART_Renderer" Value="1.0"/>
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="PartAnimated" TargetType="{x:Type bh:ActiveIcon}">
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect ShadowDepth="2" BlurRadius="5" Opacity="0.6"/>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type bh:ActiveIcon}">
                        <bh:Icon x:Name="PART_Renderer" Source="{TemplateBinding Source}" 
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                Margin="{TemplateBinding Padding}" Opacity="0.8"/>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="ColorTransform" TargetName="PART_Renderer">
                                    <Setter.Value>
                                        <bh:DesaturationTransform Amount="1.0"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition  Property="IsActive" Value="True"/>
                                    <Condition  Property="IsEnabled" Value="True"/>
                                </MultiTrigger.Conditions>
                                <MultiTrigger.EnterActions>
                                    <BeginStoryboard>
                                        <BeginStoryboard.Storyboard>
                                            <Storyboard >
                                                <DoubleAnimation To="1.0" Duration="0:0:0.3" Storyboard.TargetName="PART_Renderer" 
                                                                 Storyboard.TargetProperty="Opacity"/>
                                            </Storyboard>
                                        </BeginStoryboard.Storyboard>
                                    </BeginStoryboard>
                                </MultiTrigger.EnterActions>
                                <MultiTrigger.ExitActions>
                                    <BeginStoryboard>
                                        <BeginStoryboard.Storyboard>
                                            <Storyboard >
                                                <DoubleAnimation Duration="0:0:0.3" 
                                                                 Storyboard.TargetName="PART_Renderer" Storyboard.TargetProperty="Opacity"/>
                                            </Storyboard>
                                        </BeginStoryboard.Storyboard>
                                    </BeginStoryboard>
                                </MultiTrigger.ExitActions>
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="FullyAnimated" TargetType="{x:Type bh:ActiveIcon}">
            <Setter Property="Effect">
                <Setter.Value>
                    <DropShadowEffect ShadowDepth="2" BlurRadius="5" Opacity="0.6"/>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type bh:ActiveIcon}">
                        <bh:Icon x:Name="PART_Renderer" Source="{TemplateBinding Source}" 
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                Margin="{TemplateBinding Padding}" Opacity="0.8">
                            <bh:Icon.ColorTransform>
                                <bh:DesaturationTransform Amount="0.0"/>
                            </bh:Icon.ColorTransform>
                        </bh:Icon>
                            
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Trigger.EnterActions>
                                    <BeginStoryboard>
                                        <BeginStoryboard.Storyboard>
                                            <Storyboard >
                                                <DoubleAnimation To="1.0" Duration="0:0:0.3" Storyboard.TargetName="PART_Renderer" 
                                                                 Storyboard.TargetProperty="ColorTransform.Amount"/>
                                            </Storyboard>
                                        </BeginStoryboard.Storyboard>
                                    </BeginStoryboard>
                                </Trigger.EnterActions>
                                <Trigger.ExitActions>
                                    <BeginStoryboard>
                                        <BeginStoryboard.Storyboard>
                                            <Storyboard >
                                                <DoubleAnimation Duration="0:0:0.3" 
                                                                 Storyboard.TargetName="PART_Renderer" Storyboard.TargetProperty="ColorTransform.Amount"/>
                                            </Storyboard>
                                        </BeginStoryboard.Storyboard>
                                    </BeginStoryboard>
                                </Trigger.ExitActions>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition  Property="IsActive" Value="True"/>
                                    <Condition  Property="IsEnabled" Value="True"/>
                                </MultiTrigger.Conditions>
                                <MultiTrigger.EnterActions>
                                    <BeginStoryboard>
                                        <BeginStoryboard.Storyboard>
                                            <Storyboard >
                                                <DoubleAnimation To="1.0" Duration="0:0:0.3" Storyboard.TargetName="PART_Renderer" 
                                                                 Storyboard.TargetProperty="Opacity"/>
                                            </Storyboard>
                                        </BeginStoryboard.Storyboard>
                                    </BeginStoryboard>
                                </MultiTrigger.EnterActions>
                                <MultiTrigger.ExitActions>
                                    <BeginStoryboard>
                                        <BeginStoryboard.Storyboard>
                                            <Storyboard >
                                                <DoubleAnimation Duration="0:0:0.3" 
                                                                 Storyboard.TargetName="PART_Renderer" Storyboard.TargetProperty="Opacity"/>
                                            </Storyboard>
                                        </BeginStoryboard.Storyboard>
                                    </BeginStoryboard>
                                </MultiTrigger.ExitActions>
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </demos:DemoItem.Resources>

    <DockPanel Margin="1" LastChildFill="true">

        <StackPanel DockPanel.Dock="Top" Margin="2" >
            <TextBlock TextWrapping="Wrap" FontWeight="Bold" FontSize="14">
                    Active Icon
            </TextBlock>
            <TextBlock TextWrapping="Wrap" Margin="0,5,0,0">      
                The element taks the <Bold>Icon</Bold> element one step further 
                in that it can be dropped into a <Bold>Button</Bold> and 
                its appearance will change depending on the state of the button.
            </TextBlock>
            <TextBlock TextWrapping="Wrap" Margin="0,5,0,0">      
                The default style will make the icon gray when the control is disabled
                and change the gamma of the icon when the mouse is over the control. All the 
                other Styles extend this default style and add a little twist.
            </TextBlock>
            <TextBlock TextWrapping="Wrap" Margin="0,5,0,0">    
                To allow all the states of the button to be accessed the following check box can
                be used to enable and disable all the buttons.
            </TextBlock>
            <CheckBox DockPanel.Dock="Top" Margin="0,5,0,5" Content="Enable" x:Name="EnabledCheck"/>
        </StackPanel>

        <Border IsEnabled="{Binding ElementName=EnabledCheck, Path=IsChecked}"
                VerticalAlignment="Top" HorizontalAlignment="Center">
            <StackPanel>
                <Button Margin="5" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left">
                    <DockPanel>
                        <bh:ActiveIcon Width="32" Height="32" SnapsToDevicePixels="True" Margin="3" 
                                       Source="{x:Static bh:ShieldIcons.Warning}"/>
                        <TextBlock Margin="3" Text="Default Style" VerticalAlignment="Center"/>
                    </DockPanel>
                </Button>
                <Button Margin="5" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left">
                    <DockPanel>
                        <bh:ActiveIcon Width="32" Height="32" SnapsToDevicePixels="True" Margin="3" Style="{DynamicResource Styled}"
                                       Source="{x:Static bh:ShieldIcons.Windows}"/>
                        <TextBlock Margin="3" Text="Simple Style" VerticalAlignment="Center"/>
                    </DockPanel>
                </Button>
                <Button Margin="5" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left">
                    <DockPanel>
                        <bh:ActiveIcon Width="32" Height="32" SnapsToDevicePixels="True" Margin="3" Style="{DynamicResource PartAnimated}"
                                       Source="{x:Static bh:ShieldIcons.Error}"/>
                        <TextBlock Margin="3" Text="Part Animated" VerticalAlignment="Center"/>
                    </DockPanel>
                </Button>
                <Button Margin="5" HorizontalAlignment="Center" HorizontalContentAlignment="Left">
                    <DockPanel>
                        <bh:ActiveIcon Width="32" Height="32" SnapsToDevicePixels="True" Margin="3" Style="{DynamicResource FullyAnimated}"
                                       Source="{x:Static bh:ShieldIcons.Tick}"/>
                        <TextBlock Margin="3" Text="Fully Animated" VerticalAlignment="Center"/>
                    </DockPanel>
                </Button>
            </StackPanel>
        </Border>
    </DockPanel>
</demos:DemoItem>
